package com.dq.Service.Impl;

import com.dq.Mapper.GradeMapper;
import com.dq.Mapper.PercentageMapper;
import com.dq.Pojo.Grade;
import com.dq.Pojo.Percentage;
import com.dq.Service.GradeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GradeServiceImpl implements GradeService {
    @Autowired
    private GradeMapper gradeMapper;

    @Override
    public void add(Grade grade) {
        gradeMapper.add(grade);
    }

    @Override
    public void update(Grade grade) {
        gradeMapper.update(grade);
    }

    @Override
    public Grade findBystuid(Integer id) {
        return gradeMapper.findBystuid(id);
    }

    @Override
    public PageInfo<Grade> findAll(Integer pageNum, Integer pageSize, String stuid,Integer courseid,Integer classid) {
        PageHelper.startPage(pageNum,pageSize);
        List<Grade> gradeList=gradeMapper.findAll(stuid,courseid,classid);
        PageInfo<Grade> pageInfo=new PageInfo<>(gradeList);
        return pageInfo;
    }

    @Override
    public void delete(Integer id) {
        gradeMapper.delete(id);
    }

    @Override
    public List<Grade> findall() {
        return gradeMapper.findall();
    }

    @Override
    public PageInfo<Grade> findstu(Integer pageNum, Integer pageSize, String stuid, String courseid) {
        PageHelper.startPage(pageNum,pageSize);
        List<Grade> gradeList=gradeMapper.findstu(stuid,courseid);
        PageInfo<Grade> pageInfo=new PageInfo<>(gradeList);
        return pageInfo;
    }
}
